home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-03-20 | 1.2 KB | 72 lines | [TEXT/CWIE] |
- unit MyAssertions;
-
- interface
-
- uses
- Types;
-
- {$ifc undefined do_debug}
- {$setc do_debug := 1}
- {$endc}
-
- {$ifc not do_debug}
- { buggy compiler $ d efinec Assert(b)}
- {$definec Assert(b) if false & (b) then begin end else begin end }
- {$definec SafeDebugStr(s)}
- {$elsec}
- {$definec Assert(b) AssertCode(b)}
- {$definec SafeDebugStr(b) DebugStr(s)}
- {$endc}
-
- {$ifc do_debug}
- procedure AssertCode (b: boolean);
- procedure AssertValidPtr (p: univ Ptr);
- procedure AssertValidPtrNil (p: univ Ptr);
- procedure AssertValidHandle (hhhh: univ Handle);
- procedure AssertValidHandleNil (hhhh: univ Handle);
- {$endc}
-
- implementation
-
- uses
- Memory;
-
- {$ifc do_debug}
- procedure AssertCode (b: boolean);
- begin
- if not b then begin
- DebugStr('Assert Failed;sc;hc');
- end;
- end;
-
- procedure AssertValidPtr (p: univ Ptr);
- begin
- Assert((p <> nil) & (not odd(ord4(p))));
- end;
-
- procedure AssertValidPtrNil (p: univ Ptr);
- begin
- if p <> nil then begin
- AssertValidPtr(p);
- end;
- end;
-
- procedure AssertValidHandle (hhhh: univ Handle);
- begin
- AssertValidPtr(hhhh);
- AssertValidPtr(hhhh^);
- Assert(RecoverHandle(hhhh^) = hhhh);
- end;
-
- procedure AssertValidHandleNil (hhhh: univ Handle);
- begin
- if hhhh <> nil then begin
- AssertValidHandle(hhhh);
- end;
- end;
- {$endc}
-
- end.
-
-
-